<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <article>
    article
  </article>
  <span>span</span>
  <script>
    /**
     * Initialize your data structure here.
     */
    var MyHashMap = function() {
      var _this = [];
      _this.__proto__ = MyHashMap.prototype;
      return _this;
    };

    /**
     * value will always be non-negative. 
     * @param {number} key 
     * @param {number} value
     * @return {void}
     */
    MyHashMap.prototype.put = function(key, value) {
      var _this = this
      var flag = false;
      if (_this.length > 0) {
        for (var i = 0; i < _this.length; i++) {
          if (_this[i][0] === key) {
            _this[i][1] = value
            flag = true;
            return;
          }

        }
        if (!flag) {
          var arr = []
          arr.push(key, value)
          Array.prototype.push.apply(_this, [arr])
        }
      } else {
        var arr = []
        arr.push(key, value)
        Array.prototype.push.apply(_this, [arr])
      }
      return _this;
    };

    /**
     * Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key 
     * @param {number} key
     * @return {number}
     */
    MyHashMap.prototype.get = function(key) {
      //   var _this
      //   if (Object.prototype.toString(this) === '[object Object]') {
      //     if (Object.keys(this).length === 0) {
      //       _this = []
      //     } else {
      //       _this = Object.entries(this)
      //     }
      //   } else {
      //     return 'error'
      //   }
      var _this = this
      if (_this.length > 0) {
        for (var i = 0; i < _this.length; i++) {
          if (_this[i][0] === key) {
            return _this[i][1]
          }
        }
      }
      return -1;
    };

    /**
     * Removes the mapping of the specified value key if this map contains a mapping for the key 
     * @param {number} key
     * @return {void}
     */
    MyHashMap.prototype.remove = function(key) {
      if (this.length > 0) {
        for (var i = 0; i < this.length; i++) {
          if (this[i][0] === key) {
            Array.prototype.splice.call(this, i, 1)
          }
        }
      }
      return -1;
    };

    /**
     * Your MyHashMap object will be instantiated and called as such:
     * var obj = new MyHashMap()
     * obj.put(key,value)
     * var param_2 = obj.get(key)
     * obj.remove(key)
     */
    var myHashMap = new MyHashMap()
    myHashMap.put(1, 1)
    myHashMap.put(2, 2);
    // myHashMap.get(1);
    console.log(myHashMap)
  </script>
</body>

</html>